<?php
declare (strict_types=1);

namespace app\controller;

use app\facade\Param;
use app\helpers\api\ApiResponse;
use app\model\Signup;
use app\model\User;
use app\model\Vegetables;
use think\facade\Db;
use think\Request;

class VegetablesController
{
    use ApiResponse;

    /**
     * 蔬菜列表
     *
     * @return \think\Response
     */
    public function index(Request $request)
    {
        $query = Vegetables::field('id,name,cost,day,create_time');
        $query = Param::vegetablesParam($request->param(), $query);
        return $this->success($query->paginate($request->param('page_size', 15)));
    }

    //添加蔬菜
    public function store(Request $request)
    {
        Vegetables::create($request->param());
        return $this->created();
    }


}
